<?php

class Core_Templates
{
	protected $path, $template, $url, $layout;
	protected static $_instance = null;

	public static function getInstance($options = array())
	{
		$_instance = get_called_class(); //PHP 5.3+
		if (null === self::$_instance) {
			self::$_instance = new $_instance($options);
		}
		return self::$_instance;
	}

	public function setOptions($options = array())
	{
		if(!empty($options))
		foreach($options as $key => $val)
		{
			$method = 'set'.ucfirst($key);
			if(method_exists($this,$method)) 
				$this->{$method}($val);
		}
		return $this;
	}

	public function getUrl($url = '')
	{
		return $this->url.rtrim($url, '/');
	}
	
	public function setUrl($url)
	{
		$this->url = empty($url)?'':(rtrim($url, '/').'/');
		return $this;
	}
	
	public function getPath($path = '')
	{
		return $this->path.trim($path, '/');
	}
	
	public function setPath($path)
	{
		$this->path = empty($path)?'':(rtrim($path, '/').'/');
		return $this;
	}
	
	public function getLayout()
	{
		return $this->layout;
	}
	
	public function setLayout($layout)
	{
		$this->layout = $layout;
		return $this;
	}
}